package com.lm;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import mapgenerator.Main;

/**
 *
 * @author Sajarwo Anggai
 */
public class Layer {

    private boolean show;
    private String name;
    private Tile tileContaner[][];
    private BufferedImage bufferLayer;
    private Main comp;

    public Layer(String name, boolean show) {
        this.name = name;
        this.show = show;
    }

    public void initContainer(int rows, int cols) {
        tileContaner = new Tile[rows][cols];
        //bufferLayer = new BufferedImage(1000, 1000, Transparency.TRANSLUCENT);
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public boolean isShow() {
        return show;
    }

    public void setShow(boolean show) {
        this.show = show;
    }

    public Tile[][] getTileContaner() {
        return tileContaner;
    }

    public BufferedImage getBufferLayer() {
        return bufferLayer;
    }

    public void draw(Graphics2D g2d, int x, int y, int w, int h, int tileW, int tileH) {
        try {
            int pos1 = 0, pos2;
            for (int i = x; i < w; i++) {
                pos2 = 0;
                for (int j = y; j < h; j++) {
                    if (tileContaner[i][j] != null) {
                        tileContaner[i][j].draw(g2d, pos1, pos2, tileW, tileH);
                    }
                    pos2++;
                }
                pos1++;
            }
            System.out.println("Beres Layer = " + getName());
        } catch (Exception e) {
        }
    }

    public void draw(Graphics2D g2d, int i, int j, int posx,int posy, int tileW, int tileH,boolean a) {
        try {
            tileContaner[i][j].draw(g2d, posx, posy, tileW, tileH);
        } catch (Exception e) {
        }
    }
}
